package model;

import javax.persistence.*;
import java.util.StringTokenizer;

/**
 * User: Станислав
 * Date: 17.08.14
 */
@Entity
@Table(name = "photo")
public class Photo {
    @Id

    @Column(name = "photo_id")
    private long id;
    @Column(name = "description")
    private String description;

    public Photo(long id, String description) {
        this.id = id;
        this.description = description;
    }



    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Photo(String fromFile) {
        StringTokenizer tokenizer = new StringTokenizer(fromFile, ",");
        this.id = Integer.parseInt(tokenizer.nextToken());
        this.description = tokenizer.nextToken();
    }

    @Override
    public String toString() {
        return "Photo{" +
                "photo_id=" + id +
                ", description='" + description + '\'' +
                '}';
    }

}
